package jpa_objects;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;

/**
 * @author Alejandro Casas
 * @version 1.0
 * @created 10-Dec-2012 1:01:03 AM
 */
@Entity
@NamedQuery(name="searchCoaches", query="Select p from Instructor p  inner join fetch p.sports_of_interest as s  inner join fetch p.city as c where s.name = :sport  and c.name = :city and c.country = :country")
@PrimaryKeyJoinColumn(name="realMail")
public class Instructor extends User {

	
	private int experience_years;
	private String birthday;
	
	private String gender;
	
	private List<User> followers;
	private Instructor_type instructor_type;
	private List<Player> clients;
	private List<Player> client_applicants;
	private List<Discount> discounts;
	//Reviews private List<Review> reviews;
	private double lat1;
	private double lng1;
	private double lat2;
	private double lng2;
	private double lat3;
	private double lng3;
	
	/**
	 * @return the lat1
	 */
	public double getLat1() {
		return lat1;
	}

	/**
	 * @param lat1 the lat1 to set
	 */
	public void setLat1(double lat1) {
		this.lat1 = lat1;
	}

	/**
	 * @return the lng1
	 */
	public double getLng1() {
		return lng1;
	}

	/**
	 * @param lng1 the lng1 to set
	 */
	public void setLng1(double lng1) {
		this.lng1 = lng1;
	}

	/**
	 * @return the lat2
	 */
	public double getLat2() {
		return lat2;
	}

	/**
	 * @param lat2 the lat2 to set
	 */
	public void setLat2(double lat2) {
		this.lat2 = lat2;
	}

	/**
	 * @return the lng2
	 */
	public double getLng2() {
		return lng2;
	}

	/**
	 * @param lng2 the lng2 to set
	 */
	public void setLng2(double lng2) {
		this.lng2 = lng2;
	}

	/**
	 * @return the lat3
	 */
	public double getLat3() {
		return lat3;
	}

	/**
	 * @param lat3 the lat3 to set
	 */
	public void setLat3(double lat3) {
		this.lat3 = lat3;
	}

	/**
	 * @return the lng3
	 */
	public double getLng3() {
		return lng3;
	}

	/**
	 * @param lng3 the lng3 to set
	 */
	public void setLng3(double lng3) {
		this.lng3 = lng3;
	}

	/**
	 * @return the experience_years
	 */
	public int getExperience_years() {
		return experience_years;
	}

	/**
	 * @param experience_years the experience_years to set
	 */
	public void setExperience_years(int experience_years) {
		this.experience_years = experience_years;
	}

	/**
	 * @return the discounts
	 */
	@OneToMany(targetEntity=Discount.class,cascade=CascadeType.ALL)
	public List<Discount> getDiscounts() {
		return discounts;
	}

	/**
	 * @param discounts the discounts to set
	 */
	public void setDiscounts(List<Discount> discounts) {
		this.discounts = discounts;
	}

	/**
	 * @return the id
	 *
	@Id
	@GeneratedValue
	public long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 *
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @return the anos_expe
	 */
	public int getAnos_expe() {
		return experience_years;
	}

	/**
	 * @param anos_expe the anos_expe to set
	 */
	public void setAnos_expe(int anos_expe) {
		this.experience_years = anos_expe;
	}

	/**
	 * @return the birthday
	 */
	public String getBirthday() {
		return birthday;
	}

	/**
	 * @param birthday the birthday to set
	 */
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	/**
	 * @return the discount
	 *
	public boolean isDiscount() {
		return discounts.size()>0?true:false;
	}

	/**
	 * @param discount the discount to set
	 *
	public void setDiscount(boolean discount) {
		this.discount = discount;
	}

	/**
	 * @return the discount_description
	 *
	public String getDiscount_description() {
		return discount_description;
	}

	/**
	 * @param discount_description the discount_description to set
	 *
	public void setDiscount_description(String discount_description) {
		this.discount_description = discount_description;
	}

	/**
	 * @return the genere
	 */
	public String getGender() {
		return gender;
	}

	/**
	 * @param genere the genere to set
	 */
	public void setGender(String genere) {
		this.gender = genere;
	}

	/**
	 * @return the followers
	 */
	@OneToMany(targetEntity=User.class,cascade=CascadeType.ALL)
	public List<User> getFollowers() {
		return followers;
	}

	/**
	 * @param followers the followers to set
	 */
	public void setFollowers(List<User> followers) {
		this.followers = followers;
	}

	/**
	 * @return the type
	 */
	@OneToOne(targetEntity=Instructor_type.class,cascade=CascadeType.ALL)
	public Instructor_type getInstructor_type() {
		return instructor_type;
	}

	/**
	 * @param type the type to set
	 */
	public void setInstructor_type(Instructor_type type) {
		this.instructor_type = type;
	}

	/**
	 * @return the clients
	 */
	@OneToMany(targetEntity=Player.class,cascade=CascadeType.ALL)
	public List<Player> getClients() {
		return clients;
	}

	/**
	 * @param clients the clients to set
	 */
	public void setClients(List<Player> clients) {
		this.clients = clients;
	}

	/**
	 * @return the client_applicants
	 */
	@OneToMany(targetEntity=Player.class,cascade=CascadeType.ALL)
	public List<Player> getClient_applicants() {
		return client_applicants;
	}

	/**
	 * @param client_applicants the client_applicants to set
	 */
	public void setClient_applicants(List<Player> client_applicants) {
		this.client_applicants = client_applicants;
	}

	/**
	 * @return the reviews
	 *Reviews 
	@OneToMany(targetEntity=Review.class,cascade=CascadeType.ALL)
	public List<Review> getReviews() {
		return reviews;
	}

	/**
	 * @param reviews the reviews to set
	 *Reviews 
	public void setReviews(List<Review> reviews) {
		this.reviews = reviews;
	}

	
	public Instructor(){

	}

	/**
	 * @param carrier
	 * @param country
	 * @param description
	 * @param joinDate
	 * @param mail
	 * @param miniPicture
	 * @param name
	 * @param num_ratings
	 * @param password
	 * @param phone
	 * @param picture
	 * @param rating
	 * @param status
	 * @param anos_expe
	 * @param birthday
	 * @param discount
	 * @param discount_description
	 * @param genere
	 * @param type
	 * @param city
	 */
	public Instructor(String carrier, String country, String description,
			String joinDate, String mail, String miniPicture, String name,
			int num_ratings, String password, String phone, String picture,
			int rating, String status, int anos_expe, String birthday,
			 String genere,
			Instructor_type type, City city,double lat1,double lng1,double lat2,double lng2
			,double lat3,double lng3) {
		super(carrier, country, description, joinDate, mail, miniPicture, name,
				num_ratings, password, phone, picture, rating, status,city);
		this.experience_years = anos_expe;
		this.lat1=lat1;
		this.lng1=lng1;
		this.lat2=lat2;
		this.lng2=lng2;
		this.lat3=lat3;
		this.lng3=lng3;
		this.birthday = birthday;
		this.discounts=new ArrayList<Discount>();
		this.gender = genere;
		this.instructor_type = type;
		
		followers=new ArrayList<User>();
		clients=new ArrayList<Player>();
		client_applicants=new ArrayList<Player>();
		//Reviews reviews=new ArrayList<Review>();
		
	}
	
	public Instructor() {
		super();
		
	}


	public void finalize() throws Throwable {
		super.finalize();
	}

}